import sys,svm

max_iter = 100
tol = 0.001
C = 1.0
plot = False

for arg in sys.argv[1:]:
    if arg.startswith('-iter='):
        max_iter = int(arg[len('-iter='):])
        print >> sys.stderr, 'max number of iteration:', max_iter,
    
    if arg.startswith('-tol='):
        tol = float(arg[len('-tol='):])
        print >> sys.stderr, 'tolerance:', tol,
        
    if arg.startswith('-C='):
        C = float(arg[len('-C='):])
        print >> sys.stderr, 'C:', C,
    if arg.startswith('-plot'):
        plot = True
    if arg.startswith('-h'):
        print >> sys.stderr,'-iter=<Max Number of Iteration>, default 100'
        print >> sys.stderr,'-tol=<minimal tolerance>, default 0.001'
        print >> sys.stderr,'-C=<soft margin>, default 1.0'
        exit()

t= svm.main(C,max_iter,tol,plot)

print t['bias']

for i in range(len(t['sv_s'])):
    print t['alpha_s'][i],
    for key,val in t['sv_s'][i].items():
        print str(key)+':'+str(val),
    print
        
